/*
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
/*
 * This file was generated.
 *  with google-apis-code-generator 1.1.1 (build: 1969-12-31 15:59:59 PST)
 */

package com.google.api.services.gan;

import com.google.api.client.googleapis.services.GoogleClient;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpMethod;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.json.JsonHttpRequest;
import com.google.api.client.http.json.JsonHttpRequestInitializer;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.JsonObjectParser;
import com.google.api.client.json.JsonString;
import com.google.common.base.Preconditions;

import java.io.IOException;

/**
 * Service definition for Gan (v1beta1).
 *
 * <p>
 * Lets you have programmatic access to your Google Affiliate Network data.
 * </p>
 *
 * <p>
 * For more information about this service, see the
 * <a href="https://code.google.com/apis/gan/" target="_blank">API Documentation</a>
 * </p>
 *
 * <p>
 * This service uses {@link JsonHttpRequestInitializer} to initialize global parameters via its
 * {@link Builder}. Sample usage:
 * </p>
 *
 * <pre>
  public class GanRequestInitializer implements JsonHttpRequestInitializer {
      public void initialize(JsonHttpRequest request) {
        GanRequest ganRequest = (GanRequest)request;
        ganRequest.setPrettyPrint(true);
        ganRequest.setKey(ClientCredentials.KEY);
    }
  }
 * </pre>
 *
 * @since 1.3.0
 * @author Google, Inc.
 */
public class Gan extends GoogleClient {

  /**
   * The default encoded base path of the service. This is determined when the library is generated
   * and normally should not be changed.
   * @deprecated (scheduled to be removed in 1.8) Use "/" + {@link #DEFAULT_SERVICE_PATH}.
   */
  @Deprecated
  public static final String DEFAULT_BASE_PATH = "/gan/v1beta1/";

  /**
   * The default encoded root URL of the service. This is determined when the library is generated
   * and normally should not be changed.
   *
   * @since 1.7
   */
  public static final String DEFAULT_ROOT_URL = "https://www.googleapis.com/";

  /**
   * The default encoded service path of the service. This is determined when the library is
   * generated and normally should not be changed.
   *
   * @since 1.7
   */
  public static final String DEFAULT_SERVICE_PATH = "gan/v1beta1/";

  /**
   * The default encoded base URL of the service. This is determined when the library is generated
   * and normally should not be changed.
   */
  public static final String DEFAULT_BASE_URL = DEFAULT_ROOT_URL + DEFAULT_SERVICE_PATH;

  /**
   * Construct a Gan instance to connect to the Gan service.
   *
   * <p>
   * Use {@link Builder} if you need to specify any of the optional parameters.
   * </p>
   *
   * @param transport The transport to use for requests
   * @param jsonFactory A factory for creating JSON parsers and serializers
   * @deprecated (scheduled to be removed in 1.8) Use
   *             {@link #Gan(HttpTransport, JsonFactory, HttpRequestInitializer)}.
   */
  @Deprecated
  public Gan(HttpTransport transport, JsonFactory jsonFactory) {
    super(transport, jsonFactory, DEFAULT_BASE_URL);
  }

  /**
   * Construct a Gan instance to connect to the Gan service.
   *
   * <p>
   * Use {@link Builder} if you need to specify any of the optional parameters.
   * </p>
   *
   * @param transport The transport to use for requests
   * @param jsonFactory A factory for creating JSON parsers and serializers
   * @param httpRequestInitializer The HTTP request initializer or {@code null} for none
   * @since 1.7
   */
  public Gan(HttpTransport transport, JsonFactory jsonFactory,
      HttpRequestInitializer httpRequestInitializer) {
    super(transport, jsonFactory, DEFAULT_ROOT_URL, DEFAULT_SERVICE_PATH, httpRequestInitializer);
  }

  /**
   * Construct a Gan instance to connect to the Gan service.
   *
   * @param transport The transport to use for requests
   * @param jsonHttpRequestInitializer The initializer to use when creating an JSON HTTP request
   * @param httpRequestInitializer The initializer to use when creating an {@link HttpRequest}
   * @param jsonFactory A factory for creating JSON parsers and serializers
   * @param jsonObjectParser JSON parser to use or {@code null} if unused
   * @param baseUrl The base URL of the service on the server
   * @param applicationName The application name to be sent in the User-Agent header of requests
   */
  @Deprecated
  Gan(
      HttpTransport transport,
      JsonHttpRequestInitializer jsonHttpRequestInitializer,
      HttpRequestInitializer httpRequestInitializer,
      JsonFactory jsonFactory,
      JsonObjectParser jsonObjectParser,
      String baseUrl,
      String applicationName) {
      super(transport,
          jsonHttpRequestInitializer,
          httpRequestInitializer,
          jsonFactory,
          jsonObjectParser,
          baseUrl,
          applicationName);
  }

  /**
   * Construct a Gan instance to connect to the Gan service.
   *
   * @param transport The transport to use for requests
   * @param jsonHttpRequestInitializer The initializer to use when creating an JSON HTTP request
   * @param httpRequestInitializer The initializer to use when creating an {@link HttpRequest}
   * @param jsonFactory A factory for creating JSON parsers and serializers
   * @param jsonObjectParser JSON parser to use or {@code null} if unused
   * @param rootUrl The root URL of the service on the server
   * @param servicePath The service path of the service on the server
   * @param applicationName The application name to be sent in the User-Agent header of requests
   */
  Gan(
      HttpTransport transport,
      JsonHttpRequestInitializer jsonHttpRequestInitializer,
      HttpRequestInitializer httpRequestInitializer,
      JsonFactory jsonFactory,
      JsonObjectParser jsonObjectParser,
      String rootUrl,
      String servicePath,
      String applicationName) {
      super(transport,
          jsonHttpRequestInitializer,
          httpRequestInitializer,
          jsonFactory,
          jsonObjectParser,
          rootUrl,
          servicePath,
          applicationName);
  }

  @Override
  protected void initialize(JsonHttpRequest jsonHttpRequest) throws IOException {
    super.initialize(jsonHttpRequest);
  }

  /**
   * Returns an instance of a new builder.
   *
   * @param transport The transport to use for requests
   * @param jsonFactory A factory for creating JSON parsers and serializers
   * @deprecated (scheduled to removed in 1.8) Use
   *             {@link Builder#Builder(HttpTransport, JsonFactory, HttpRequestInitializer)}.
   */
   @Deprecated
   public static Builder builder(HttpTransport transport, JsonFactory jsonFactory) {
     return new Builder(transport, jsonFactory, new GenericUrl(DEFAULT_BASE_URL));
   }

  /**
   * An accessor for creating requests from the Advertisers collection.
   *
   * The typical use is:<pre>
   *   {@code Gan gan = new Gan(...);}
   *   {@code Gan.Advertisers.List request = gan.advertisers().list(parameters ...)}</pre>
   *
   * @return the resource collection
   */
  public Advertisers advertisers() {
    return new Advertisers();
  }

  /**
   * The "advertisers" collection of methods.
   */
  public class Advertisers {

    /**
     * Retrieves data about all advertisers that the requesting advertiser/publisher has access to.
     *
     * Create a request for the method "advertisers.list".
     *
     * This request holds the parameters needed by the the gan server.  After setting any optional
     * parameters, call the {@link List#execute()} method to invoke the remote operation.
     *
     * @param role The role of the requester. Valid values: 'advertisers' or 'publishers'.
     * @param roleId The ID of the requesting advertiser or publisher.
     * @return the request
     * @throws IOException if the initialization of the request fails
     */
    public List list(String role, String roleId) throws IOException {
      List result = new List(role, roleId);
      initialize(result);
      return result;
    }

    public class List extends GanRequest {

      private static final String REST_PATH = "{role}/{roleId}/advertisers";

      /**
       * Internal constructor.  Use the convenience method instead.
       */
      List(String role, String roleId) {
        super(Gan.this, HttpMethod.GET, REST_PATH, null);
        this.role = Preconditions.checkNotNull(role, "Required parameter role must be specified.");
        this.roleId = Preconditions.checkNotNull(roleId, "Required parameter roleId must be specified.");
      }

      /**
       * Sends the "list" request to the Gan server.
       *
       * @return the {@link com.google.api.services.gan.model.Advertisers} response
       * @throws IOException if the request fails
       */
      public com.google.api.services.gan.model.Advertisers execute() throws IOException {
        HttpResponse response = executeUnparsed();
        com.google.api.services.gan.model.Advertisers result = response.parseAs(
            com.google.api.services.gan.model.Advertisers.class);
        result.setResponseHeaders(response.getHeaders());
        return result;
      }

      /**
       * Queues the "list" request to the Gan server into the given batch request.
       *
       * <p>
       * Example usage:
       * </p>
       *
       * <pre>
         request.queue(batchRequest, new JsonBatchCallback&lt;Advertisers&gt;() {

           public void onSuccess(Advertisers content, GoogleHeaders responseHeaders) {
             log("Success");
           }

           public void onFailure(GoogleJsonError e, GoogleHeaders responseHeaders) {
             log(e.getMessage());
           }
         });
       * </pre>
       *
       * @param batch a single batch of requests
       * @param callback batch callback
       * @since 1.6
       */
      public void queue(com.google.api.client.googleapis.batch.BatchRequest batch,
          com.google.api.client.googleapis.batch.json.JsonBatchCallback<com.google.api.services.gan.model.Advertisers> callback)
          throws IOException {
        batch.queue(buildHttpRequest(), com.google.api.services.gan.model.Advertisers.class,
            com.google.api.client.googleapis.json.GoogleJsonErrorContainer.class, callback);
      }

      /**
       * @since 1.7
       */
      @Override
      public List setFields(String fields) {
        super.setFields(fields);
        return this;
      }

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      @com.google.api.client.util.Key
      private String role;

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'.
       */
      public String getRole() {
        return role;
      }

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      public List setRole(String role) {
        this.role = role;
        return this;
      }

      /** The ID of the requesting advertiser or publisher. */
      @com.google.api.client.util.Key
      private String roleId;

      /** The ID of the requesting advertiser or publisher.
       */
      public String getRoleId() {
        return roleId;
      }

      /** The ID of the requesting advertiser or publisher. */
      public List setRoleId(String roleId) {
        this.roleId = roleId;
        return this;
      }

      /**
     * Filters out all advertisers for which do not have the given relationship status with the
     * requesting publisher.
     */
      @com.google.api.client.util.Key
      private String relationshipStatus;

      /** Filters out all advertisers for which do not have the given relationship status with the requesting
     publisher.
       */
      public String getRelationshipStatus() {
        return relationshipStatus;
      }

      /**
     * Filters out all advertisers for which do not have the given relationship status with the
     * requesting publisher.
     */
      public List setRelationshipStatus(String relationshipStatus) {
        this.relationshipStatus = relationshipStatus;
        return this;
      }

      /**
     * Filters out all advertisers that have a seven day EPC average lower than the given value
     * (inclusive). Min value: 0.0. Optional.
     */
      @com.google.api.client.util.Key
      private Double minSevenDayEpc;

      /** Filters out all advertisers that have a seven day EPC average lower than the given value
     (inclusive). Min value: 0.0. Optional.
       */
      public Double getMinSevenDayEpc() {
        return minSevenDayEpc;
      }

      /**
     * Filters out all advertisers that have a seven day EPC average lower than the given value
     * (inclusive). Min value: 0.0. Optional.
     */
      public List setMinSevenDayEpc(Double minSevenDayEpc) {
        this.minSevenDayEpc = minSevenDayEpc;
        return this;
      }

      /**
     * Caret(^) delimted list of advertiser categories. Valid categories are defined here:
     * http://www.google.com/support/affiliatenetwork/advertiser/bin/answer.py?hl=en=107581. Filters
     * out all advertisers not in one of the given advertiser categories. Optional.
     */
      @com.google.api.client.util.Key
      private String advertiserCategory;

      /** Caret(^) delimted list of advertiser categories. Valid categories are defined here:
     http://www.google.com/support/affiliatenetwork/advertiser/bin/answer.py?hl=en=107581. Filters out
     all advertisers not in one of the given advertiser categories. Optional.
       */
      public String getAdvertiserCategory() {
        return advertiserCategory;
      }

      /**
     * Caret(^) delimted list of advertiser categories. Valid categories are defined here:
     * http://www.google.com/support/affiliatenetwork/advertiser/bin/answer.py?hl=en=107581. Filters
     * out all advertisers not in one of the given advertiser categories. Optional.
     */
      public List setAdvertiserCategory(String advertiserCategory) {
        this.advertiserCategory = advertiserCategory;
        return this;
      }

      /**
     * Filters out all advertisers that have a ninety day EPC average lower than the given value
     * (inclusive). Min value: 0.0. Optional.
     */
      @com.google.api.client.util.Key
      private Double minNinetyDayEpc;

      /** Filters out all advertisers that have a ninety day EPC average lower than the given value
     (inclusive). Min value: 0.0. Optional.
       */
      public Double getMinNinetyDayEpc() {
        return minNinetyDayEpc;
      }

      /**
     * Filters out all advertisers that have a ninety day EPC average lower than the given value
     * (inclusive). Min value: 0.0. Optional.
     */
      public List setMinNinetyDayEpc(Double minNinetyDayEpc) {
        this.minNinetyDayEpc = minNinetyDayEpc;
        return this;
      }

      /** The value of 'nextPageToken' from the previous page. Optional. */
      @com.google.api.client.util.Key
      private String pageToken;

      /** The value of 'nextPageToken' from the previous page. Optional.
       */
      public String getPageToken() {
        return pageToken;
      }

      /** The value of 'nextPageToken' from the previous page. Optional. */
      public List setPageToken(String pageToken) {
        this.pageToken = pageToken;
        return this;
      }

      /** Max number of items to return in this page. Optional. Defaults to 20. */
      @com.google.api.client.util.Key
      private Long maxResults;

      /** Max number of items to return in this page. Optional. Defaults to 20.

     [minimum: 0] [maximum: 100]
       */
      public Long getMaxResults() {
        return maxResults;
      }

      /** Max number of items to return in this page. Optional. Defaults to 20. */
      public List setMaxResults(Long maxResults) {
        this.maxResults = maxResults;
        return this;
      }

      /**
     * A value between 1 and 4, where 1 represents the quartile of advertisers with the lowest ranks
     * and 4 represents the quartile of advertisers with the highest ranks. Filters out all
     * advertisers with a lower rank than the given quartile. For example if a 2 was given only
     * advertisers with a payout rank of 25 or higher would be included. Optional.
     */
      @com.google.api.client.util.Key
      private Integer minPayoutRank;

      /** A value between 1 and 4, where 1 represents the quartile of advertisers with the lowest ranks and 4
     represents the quartile of advertisers with the highest ranks. Filters out all advertisers with a
     lower rank than the given quartile. For example if a 2 was given only advertisers with a payout
     rank of 25 or higher would be included. Optional.

     [minimum: 1] [maximum: 4]
       */
      public Integer getMinPayoutRank() {
        return minPayoutRank;
      }

      /**
     * A value between 1 and 4, where 1 represents the quartile of advertisers with the lowest ranks
     * and 4 represents the quartile of advertisers with the highest ranks. Filters out all
     * advertisers with a lower rank than the given quartile. For example if a 2 was given only
     * advertisers with a payout rank of 25 or higher would be included. Optional.
     */
      public List setMinPayoutRank(Integer minPayoutRank) {
        this.minPayoutRank = minPayoutRank;
        return this;
      }

    }
    /**
     * Retrieves data about a single advertiser if that the requesting advertiser/publisher has access
     * to it. Only publishers can lookup advertisers. Advertisers can request information about
     * themselves by omitting the advertiserId query parameter.
     *
     * Create a request for the method "advertisers.get".
     *
     * This request holds the parameters needed by the the gan server.  After setting any optional
     * parameters, call the {@link Get#execute()} method to invoke the remote operation.
     *
     * @param role The role of the requester. Valid values: 'advertisers' or 'publishers'.
     * @param roleId The ID of the requesting advertiser or publisher.
     * @return the request
     * @throws IOException if the initialization of the request fails
     */
    public Get get(String role, String roleId) throws IOException {
      Get result = new Get(role, roleId);
      initialize(result);
      return result;
    }

    public class Get extends GanRequest {

      private static final String REST_PATH = "{role}/{roleId}/advertiser";

      /**
       * Internal constructor.  Use the convenience method instead.
       */
      Get(String role, String roleId) {
        super(Gan.this, HttpMethod.GET, REST_PATH, null);
        this.role = Preconditions.checkNotNull(role, "Required parameter role must be specified.");
        this.roleId = Preconditions.checkNotNull(roleId, "Required parameter roleId must be specified.");
      }

      /**
       * Sends the "get" request to the Gan server.
       *
       * @return the {@link com.google.api.services.gan.model.Advertiser} response
       * @throws IOException if the request fails
       */
      public com.google.api.services.gan.model.Advertiser execute() throws IOException {
        HttpResponse response = executeUnparsed();
        com.google.api.services.gan.model.Advertiser result = response.parseAs(
            com.google.api.services.gan.model.Advertiser.class);
        result.setResponseHeaders(response.getHeaders());
        return result;
      }

      /**
       * Queues the "get" request to the Gan server into the given batch request.
       *
       * <p>
       * Example usage:
       * </p>
       *
       * <pre>
         request.queue(batchRequest, new JsonBatchCallback&lt;Advertiser&gt;() {

           public void onSuccess(Advertiser content, GoogleHeaders responseHeaders) {
             log("Success");
           }

           public void onFailure(GoogleJsonError e, GoogleHeaders responseHeaders) {
             log(e.getMessage());
           }
         });
       * </pre>
       *
       * @param batch a single batch of requests
       * @param callback batch callback
       * @since 1.6
       */
      public void queue(com.google.api.client.googleapis.batch.BatchRequest batch,
          com.google.api.client.googleapis.batch.json.JsonBatchCallback<com.google.api.services.gan.model.Advertiser> callback)
          throws IOException {
        batch.queue(buildHttpRequest(), com.google.api.services.gan.model.Advertiser.class,
            com.google.api.client.googleapis.json.GoogleJsonErrorContainer.class, callback);
      }

      /**
       * @since 1.7
       */
      @Override
      public Get setFields(String fields) {
        super.setFields(fields);
        return this;
      }

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      @com.google.api.client.util.Key
      private String role;

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'.
       */
      public String getRole() {
        return role;
      }

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      public Get setRole(String role) {
        this.role = role;
        return this;
      }

      /** The ID of the requesting advertiser or publisher. */
      @com.google.api.client.util.Key
      private String roleId;

      /** The ID of the requesting advertiser or publisher.
       */
      public String getRoleId() {
        return roleId;
      }

      /** The ID of the requesting advertiser or publisher. */
      public Get setRoleId(String roleId) {
        this.roleId = roleId;
        return this;
      }

      /** The ID of the advertiser to look up. Optional. */
      @com.google.api.client.util.Key
      private String advertiserId;

      /** The ID of the advertiser to look up. Optional.
       */
      public String getAdvertiserId() {
        return advertiserId;
      }

      /** The ID of the advertiser to look up. Optional. */
      public Get setAdvertiserId(String advertiserId) {
        this.advertiserId = advertiserId;
        return this;
      }

    }

  }

  /**
   * An accessor for creating requests from the CcOffers collection.
   *
   * The typical use is:<pre>
   *   {@code Gan gan = new Gan(...);}
   *   {@code Gan.CcOffers.List request = gan.ccOffers().list(parameters ...)}</pre>
   *
   * @return the resource collection
   */
  public CcOffers ccOffers() {
    return new CcOffers();
  }

  /**
   * The "ccOffers" collection of methods.
   */
  public class CcOffers {

    /**
     * Retrieves credit card offers for the given publisher.
     *
     * Create a request for the method "ccOffers.list".
     *
     * This request holds the parameters needed by the the gan server.  After setting any optional
     * parameters, call the {@link List#execute()} method to invoke the remote operation.
     *
     * @param publisher The ID of the publisher in question.
     * @return the request
     * @throws IOException if the initialization of the request fails
     */
    public List list(String publisher) throws IOException {
      List result = new List(publisher);
      initialize(result);
      return result;
    }

    public class List extends GanRequest {

      private static final String REST_PATH = "publishers/{publisher}/ccOffers";

      /**
       * Internal constructor.  Use the convenience method instead.
       */
      List(String publisher) {
        super(Gan.this, HttpMethod.GET, REST_PATH, null);
        this.publisher = Preconditions.checkNotNull(publisher, "Required parameter publisher must be specified.");
      }

      /**
       * Sends the "list" request to the Gan server.
       *
       * @return the {@link com.google.api.services.gan.model.CcOffers} response
       * @throws IOException if the request fails
       */
      public com.google.api.services.gan.model.CcOffers execute() throws IOException {
        HttpResponse response = executeUnparsed();
        com.google.api.services.gan.model.CcOffers result = response.parseAs(
            com.google.api.services.gan.model.CcOffers.class);
        result.setResponseHeaders(response.getHeaders());
        return result;
      }

      /**
       * Queues the "list" request to the Gan server into the given batch request.
       *
       * <p>
       * Example usage:
       * </p>
       *
       * <pre>
         request.queue(batchRequest, new JsonBatchCallback&lt;CcOffers&gt;() {

           public void onSuccess(CcOffers content, GoogleHeaders responseHeaders) {
             log("Success");
           }

           public void onFailure(GoogleJsonError e, GoogleHeaders responseHeaders) {
             log(e.getMessage());
           }
         });
       * </pre>
       *
       * @param batch a single batch of requests
       * @param callback batch callback
       * @since 1.6
       */
      public void queue(com.google.api.client.googleapis.batch.BatchRequest batch,
          com.google.api.client.googleapis.batch.json.JsonBatchCallback<com.google.api.services.gan.model.CcOffers> callback)
          throws IOException {
        batch.queue(buildHttpRequest(), com.google.api.services.gan.model.CcOffers.class,
            com.google.api.client.googleapis.json.GoogleJsonErrorContainer.class, callback);
      }

      /**
       * @since 1.7
       */
      @Override
      public List setFields(String fields) {
        super.setFields(fields);
        return this;
      }

      /** The ID of the publisher in question. */
      @com.google.api.client.util.Key
      private String publisher;

      /** The ID of the publisher in question.
       */
      public String getPublisher() {
        return publisher;
      }

      /** The ID of the publisher in question. */
      public List setPublisher(String publisher) {
        this.publisher = publisher;
        return this;
      }

      /** The advertiser ID of a card issuer whose offers to include. Optional, may be repeated. */
      @com.google.api.client.util.Key
      private java.util.List<String> advertiser;

      /** The advertiser ID of a card issuer whose offers to include. Optional, may be repeated.
       */
      public java.util.List<String> getAdvertiser() {
        return advertiser;
      }

      /** The advertiser ID of a card issuer whose offers to include. Optional, may be repeated. */
      public List setAdvertiser(java.util.List<String> advertiser) {
        this.advertiser = advertiser;
        return this;
      }

      /** The set of fields to return. */
      @com.google.api.client.util.Key
      private String projection;

      /** The set of fields to return.
       */
      public String getProjection() {
        return projection;
      }

      /** The set of fields to return. */
      public List setProjection(String projection) {
        this.projection = projection;
        return this;
      }

    }

  }

  /**
   * An accessor for creating requests from the Events collection.
   *
   * The typical use is:<pre>
   *   {@code Gan gan = new Gan(...);}
   *   {@code Gan.Events.List request = gan.events().list(parameters ...)}</pre>
   *
   * @return the resource collection
   */
  public Events events() {
    return new Events();
  }

  /**
   * The "events" collection of methods.
   */
  public class Events {

    /**
     * Retrieves event data for a given advertiser/publisher.
     *
     * Create a request for the method "events.list".
     *
     * This request holds the parameters needed by the the gan server.  After setting any optional
     * parameters, call the {@link List#execute()} method to invoke the remote operation.
     *
     * @param role The role of the requester. Valid values: 'advertisers' or 'publishers'.
     * @param roleId The ID of the requesting advertiser or publisher.
     * @return the request
     * @throws IOException if the initialization of the request fails
     */
    public List list(String role, String roleId) throws IOException {
      List result = new List(role, roleId);
      initialize(result);
      return result;
    }

    public class List extends GanRequest {

      private static final String REST_PATH = "{role}/{roleId}/events";

      /**
       * Internal constructor.  Use the convenience method instead.
       */
      List(String role, String roleId) {
        super(Gan.this, HttpMethod.GET, REST_PATH, null);
        this.role = Preconditions.checkNotNull(role, "Required parameter role must be specified.");
        this.roleId = Preconditions.checkNotNull(roleId, "Required parameter roleId must be specified.");
      }

      /**
       * Sends the "list" request to the Gan server.
       *
       * @return the {@link com.google.api.services.gan.model.Events} response
       * @throws IOException if the request fails
       */
      public com.google.api.services.gan.model.Events execute() throws IOException {
        HttpResponse response = executeUnparsed();
        com.google.api.services.gan.model.Events result = response.parseAs(
            com.google.api.services.gan.model.Events.class);
        result.setResponseHeaders(response.getHeaders());
        return result;
      }

      /**
       * Queues the "list" request to the Gan server into the given batch request.
       *
       * <p>
       * Example usage:
       * </p>
       *
       * <pre>
         request.queue(batchRequest, new JsonBatchCallback&lt;Events&gt;() {

           public void onSuccess(Events content, GoogleHeaders responseHeaders) {
             log("Success");
           }

           public void onFailure(GoogleJsonError e, GoogleHeaders responseHeaders) {
             log(e.getMessage());
           }
         });
       * </pre>
       *
       * @param batch a single batch of requests
       * @param callback batch callback
       * @since 1.6
       */
      public void queue(com.google.api.client.googleapis.batch.BatchRequest batch,
          com.google.api.client.googleapis.batch.json.JsonBatchCallback<com.google.api.services.gan.model.Events> callback)
          throws IOException {
        batch.queue(buildHttpRequest(), com.google.api.services.gan.model.Events.class,
            com.google.api.client.googleapis.json.GoogleJsonErrorContainer.class, callback);
      }

      /**
       * @since 1.7
       */
      @Override
      public List setFields(String fields) {
        super.setFields(fields);
        return this;
      }

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      @com.google.api.client.util.Key
      private String role;

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'.
       */
      public String getRole() {
        return role;
      }

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      public List setRole(String role) {
        this.role = role;
        return this;
      }

      /** The ID of the requesting advertiser or publisher. */
      @com.google.api.client.util.Key
      private String roleId;

      /** The ID of the requesting advertiser or publisher.
       */
      public String getRoleId() {
        return roleId;
      }

      /** The ID of the requesting advertiser or publisher. */
      public List setRoleId(String roleId) {
        this.roleId = roleId;
        return this;
      }

      /**
     * Caret(^) delimited list of order IDs. Filters out all events that do not reference one of the
     * given order IDs. Optional.
     */
      @com.google.api.client.util.Key
      private String orderId;

      /** Caret(^) delimited list of order IDs. Filters out all events that do not reference one of the given
     order IDs. Optional.
       */
      public String getOrderId() {
        return orderId;
      }

      /**
     * Caret(^) delimited list of order IDs. Filters out all events that do not reference one of the
     * given order IDs. Optional.
     */
      public List setOrderId(String orderId) {
        this.orderId = orderId;
        return this;
      }

      /**
     * Caret(^) delimited list of SKUs. Filters out all events that do not reference one of the
     * given SKU. Optional.
     */
      @com.google.api.client.util.Key
      private String sku;

      /** Caret(^) delimited list of SKUs. Filters out all events that do not reference one of the given SKU.
     Optional.
       */
      public String getSku() {
        return sku;
      }

      /**
     * Caret(^) delimited list of SKUs. Filters out all events that do not reference one of the
     * given SKU. Optional.
     */
      public List setSku(String sku) {
        this.sku = sku;
        return this;
      }

      /**
     * Filters out all events later than given date. Optional. Defaults to 24 hours after eventMin.
     */
      @com.google.api.client.util.Key
      private String eventDateMax;

      /** Filters out all events later than given date. Optional. Defaults to 24 hours after eventMin.
       */
      public String getEventDateMax() {
        return eventDateMax;
      }

      /**
     * Filters out all events later than given date. Optional. Defaults to 24 hours after eventMin.
     */
      public List setEventDateMax(String eventDateMax) {
        this.eventDateMax = eventDateMax;
        return this;
      }

      /**
     * Filters out all events that are not of the given type. Valid values: 'action', 'transaction',
     * 'charge'. Optional.
     */
      @com.google.api.client.util.Key
      private String type;

      /** Filters out all events that are not of the given type. Valid values: 'action', 'transaction',
     'charge'. Optional.
       */
      public String getType() {
        return type;
      }

      /**
     * Filters out all events that are not of the given type. Valid values: 'action', 'transaction',
     * 'charge'. Optional.
     */
      public List setType(String type) {
        this.type = type;
        return this;
      }

      /**
     * Caret(^) delimited list of link IDs. Filters out all events that do not reference one of the
     * given link IDs. Optional.
     */
      @com.google.api.client.util.Key
      private String linkId;

      /** Caret(^) delimited list of link IDs. Filters out all events that do not reference one of the given
     link IDs. Optional.
       */
      public String getLinkId() {
        return linkId;
      }

      /**
     * Caret(^) delimited list of link IDs. Filters out all events that do not reference one of the
     * given link IDs. Optional.
     */
      public List setLinkId(String linkId) {
        this.linkId = linkId;
        return this;
      }

      /**
     * Filters out all events modified earlier than given date. Optional. Defaults to 24 hours
     * before the current modifyDateMax, if modifyDateMax is explicitly set.
     */
      @com.google.api.client.util.Key
      private String modifyDateMin;

      /** Filters out all events modified earlier than given date. Optional. Defaults to 24 hours before the
     current modifyDateMax, if modifyDateMax is explicitly set.
       */
      public String getModifyDateMin() {
        return modifyDateMin;
      }

      /**
     * Filters out all events modified earlier than given date. Optional. Defaults to 24 hours
     * before the current modifyDateMax, if modifyDateMax is explicitly set.
     */
      public List setModifyDateMin(String modifyDateMin) {
        this.modifyDateMin = modifyDateMin;
        return this;
      }

      /**
     * Filters out all events earlier than given date. Optional. Defaults to 24 hours from current
     * date/time.
     */
      @com.google.api.client.util.Key
      private String eventDateMin;

      /** Filters out all events earlier than given date. Optional. Defaults to 24 hours from current
     date/time.
       */
      public String getEventDateMin() {
        return eventDateMin;
      }

      /**
     * Filters out all events earlier than given date. Optional. Defaults to 24 hours from current
     * date/time.
     */
      public List setEventDateMin(String eventDateMin) {
        this.eventDateMin = eventDateMin;
        return this;
      }

      /**
     * Caret(^) delimited list of member IDs. Filters out all events that do not reference one of
     * the given member IDs. Optional.
     */
      @com.google.api.client.util.Key
      private String memberId;

      /** Caret(^) delimited list of member IDs. Filters out all events that do not reference one of the
     given member IDs. Optional.
       */
      public String getMemberId() {
        return memberId;
      }

      /**
     * Caret(^) delimited list of member IDs. Filters out all events that do not reference one of
     * the given member IDs. Optional.
     */
      public List setMemberId(String memberId) {
        this.memberId = memberId;
        return this;
      }

      /** Max number of offers to return in this page. Optional. Defaults to 20. */
      @com.google.api.client.util.Key
      private Long maxResults;

      /** Max number of offers to return in this page. Optional. Defaults to 20.

     [minimum: 0] [maximum: 100]
       */
      public Long getMaxResults() {
        return maxResults;
      }

      /** Max number of offers to return in this page. Optional. Defaults to 20. */
      public List setMaxResults(Long maxResults) {
        this.maxResults = maxResults;
        return this;
      }

      /**
     * Caret(^) delimited list of advertiser IDs. Filters out all events that do not reference one
     * of the given advertiser IDs. Only used when under publishers role. Optional.
     */
      @com.google.api.client.util.Key
      private String advertiserId;

      /** Caret(^) delimited list of advertiser IDs. Filters out all events that do not reference one of the
     given advertiser IDs. Only used when under publishers role. Optional.
       */
      public String getAdvertiserId() {
        return advertiserId;
      }

      /**
     * Caret(^) delimited list of advertiser IDs. Filters out all events that do not reference one
     * of the given advertiser IDs. Only used when under publishers role. Optional.
     */
      public List setAdvertiserId(String advertiserId) {
        this.advertiserId = advertiserId;
        return this;
      }

      /** The value of 'nextPageToken' from the previous page. Optional. */
      @com.google.api.client.util.Key
      private String pageToken;

      /** The value of 'nextPageToken' from the previous page. Optional.
       */
      public String getPageToken() {
        return pageToken;
      }

      /** The value of 'nextPageToken' from the previous page. Optional. */
      public List setPageToken(String pageToken) {
        this.pageToken = pageToken;
        return this;
      }

      /**
     * Caret(^) delimited list of product categories. Filters out all events that do not reference a
     * product in one of the given product categories. Optional.
     */
      @com.google.api.client.util.Key
      private String productCategory;

      /** Caret(^) delimited list of product categories. Filters out all events that do not reference a
     product in one of the given product categories. Optional.
       */
      public String getProductCategory() {
        return productCategory;
      }

      /**
     * Caret(^) delimited list of product categories. Filters out all events that do not reference a
     * product in one of the given product categories. Optional.
     */
      public List setProductCategory(String productCategory) {
        this.productCategory = productCategory;
        return this;
      }

      /**
     * Filters out all charge events that are not of the given charge type. Valid values: 'other',
     * 'slotting_fee', 'monthly_minimum', 'tier_bonus', 'credit', 'debit'. Optional.
     */
      @com.google.api.client.util.Key
      private String chargeType;

      /** Filters out all charge events that are not of the given charge type. Valid values: 'other',
     'slotting_fee', 'monthly_minimum', 'tier_bonus', 'credit', 'debit'. Optional.
       */
      public String getChargeType() {
        return chargeType;
      }

      /**
     * Filters out all charge events that are not of the given charge type. Valid values: 'other',
     * 'slotting_fee', 'monthly_minimum', 'tier_bonus', 'credit', 'debit'. Optional.
     */
      public List setChargeType(String chargeType) {
        this.chargeType = chargeType;
        return this;
      }

      /**
     * Filters out all events modified later than given date. Optional. Defaults to 24 hours after
     * modifyDateMin, if modifyDateMin is explicitly set.
     */
      @com.google.api.client.util.Key
      private String modifyDateMax;

      /** Filters out all events modified later than given date. Optional. Defaults to 24 hours after
     modifyDateMin, if modifyDateMin is explicitly set.
       */
      public String getModifyDateMax() {
        return modifyDateMax;
      }

      /**
     * Filters out all events modified later than given date. Optional. Defaults to 24 hours after
     * modifyDateMin, if modifyDateMin is explicitly set.
     */
      public List setModifyDateMax(String modifyDateMax) {
        this.modifyDateMax = modifyDateMax;
        return this;
      }

      /**
     * Filters out all events that do not have the given status. Valid values: 'active', 'canceled'.
     * Optional.
     */
      @com.google.api.client.util.Key
      private String status;

      /** Filters out all events that do not have the given status. Valid values: 'active', 'canceled'.
     Optional.
       */
      public String getStatus() {
        return status;
      }

      /**
     * Filters out all events that do not have the given status. Valid values: 'active', 'canceled'.
     * Optional.
     */
      public List setStatus(String status) {
        this.status = status;
        return this;
      }

      /**
     * Caret(^) delimited list of publisher IDs. Filters out all events that do not reference one of
     * the given publishers IDs. Only used when under advertiser role. Optional.
     */
      @com.google.api.client.util.Key
      private String publisherId;

      /** Caret(^) delimited list of publisher IDs. Filters out all events that do not reference one of the
     given publishers IDs. Only used when under advertiser role. Optional.
       */
      public String getPublisherId() {
        return publisherId;
      }

      /**
     * Caret(^) delimited list of publisher IDs. Filters out all events that do not reference one of
     * the given publishers IDs. Only used when under advertiser role. Optional.
     */
      public List setPublisherId(String publisherId) {
        this.publisherId = publisherId;
        return this;
      }

    }

  }

  /**
   * An accessor for creating requests from the Links collection.
   *
   * The typical use is:<pre>
   *   {@code Gan gan = new Gan(...);}
   *   {@code Gan.Links.List request = gan.links().list(parameters ...)}</pre>
   *
   * @return the resource collection
   */
  public Links links() {
    return new Links();
  }

  /**
   * The "links" collection of methods.
   */
  public class Links {

    /**
     * Inserts a new link.
     *
     * Create a request for the method "links.insert".
     *
     * This request holds the parameters needed by the the gan server.  After setting any optional
     * parameters, call the {@link Insert#execute()} method to invoke the remote operation.
     *
     * @param role The role of the requester. Valid values: 'advertisers' or 'publishers'.
     * @param roleId The ID of the requesting advertiser or publisher.
     * @param content the {@link com.google.api.services.gan.model.Link}
     * @return the request
     * @throws IOException if the initialization of the request fails
     */
    public Insert insert(String role, String roleId, com.google.api.services.gan.model.Link content) throws IOException {
      Insert result = new Insert(role, roleId, content);
      initialize(result);
      return result;
    }

    public class Insert extends GanRequest {

      private static final String REST_PATH = "{role}/{roleId}/link";

      /**
       * Internal constructor.  Use the convenience method instead.
       */
      Insert(String role, String roleId, com.google.api.services.gan.model.Link content) {
        super(Gan.this, HttpMethod.POST, REST_PATH, content);
        this.role = Preconditions.checkNotNull(role, "Required parameter role must be specified.");
        this.roleId = Preconditions.checkNotNull(roleId, "Required parameter roleId must be specified.");
        Preconditions.checkNotNull(content);
      }

      /**
       * Sends the "insert" request to the Gan server.
       *
       * @return the {@link com.google.api.services.gan.model.Link} response
       * @throws IOException if the request fails
       */
      public com.google.api.services.gan.model.Link execute() throws IOException {
        HttpResponse response = executeUnparsed();
        com.google.api.services.gan.model.Link result = response.parseAs(
            com.google.api.services.gan.model.Link.class);
        result.setResponseHeaders(response.getHeaders());
        return result;
      }

      /**
       * Queues the "insert" request to the Gan server into the given batch request.
       *
       * <p>
       * Example usage:
       * </p>
       *
       * <pre>
         request.queue(batchRequest, new JsonBatchCallback&lt;Link&gt;() {

           public void onSuccess(Link content, GoogleHeaders responseHeaders) {
             log("Success");
           }

           public void onFailure(GoogleJsonError e, GoogleHeaders responseHeaders) {
             log(e.getMessage());
           }
         });
       * </pre>
       *
       * @param batch a single batch of requests
       * @param callback batch callback
       * @since 1.6
       */
      public void queue(com.google.api.client.googleapis.batch.BatchRequest batch,
          com.google.api.client.googleapis.batch.json.JsonBatchCallback<com.google.api.services.gan.model.Link> callback)
          throws IOException {
        batch.queue(buildHttpRequest(), com.google.api.services.gan.model.Link.class,
            com.google.api.client.googleapis.json.GoogleJsonErrorContainer.class, callback);
      }

      /**
       * @since 1.7
       */
      @Override
      public Insert setFields(String fields) {
        super.setFields(fields);
        return this;
      }

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      @com.google.api.client.util.Key
      private String role;

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'.
       */
      public String getRole() {
        return role;
      }

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      public Insert setRole(String role) {
        this.role = role;
        return this;
      }

      /** The ID of the requesting advertiser or publisher. */
      @com.google.api.client.util.Key
      private String roleId;

      /** The ID of the requesting advertiser or publisher.
       */
      public String getRoleId() {
        return roleId;
      }

      /** The ID of the requesting advertiser or publisher. */
      public Insert setRoleId(String roleId) {
        this.roleId = roleId;
        return this;
      }

    }
    /**
     * Retrieves all links that match the query parameters.
     *
     * Create a request for the method "links.list".
     *
     * This request holds the parameters needed by the the gan server.  After setting any optional
     * parameters, call the {@link List#execute()} method to invoke the remote operation.
     *
     * @param role The role of the requester. Valid values: 'advertisers' or 'publishers'.
     * @param roleId The ID of the requesting advertiser or publisher.
     * @return the request
     * @throws IOException if the initialization of the request fails
     */
    public List list(String role, String roleId) throws IOException {
      List result = new List(role, roleId);
      initialize(result);
      return result;
    }

    public class List extends GanRequest {

      private static final String REST_PATH = "{role}/{roleId}/links";

      /**
       * Internal constructor.  Use the convenience method instead.
       */
      List(String role, String roleId) {
        super(Gan.this, HttpMethod.GET, REST_PATH, null);
        this.role = Preconditions.checkNotNull(role, "Required parameter role must be specified.");
        this.roleId = Preconditions.checkNotNull(roleId, "Required parameter roleId must be specified.");
      }

      /**
       * Sends the "list" request to the Gan server.
       *
       * @return the {@link com.google.api.services.gan.model.Links} response
       * @throws IOException if the request fails
       */
      public com.google.api.services.gan.model.Links execute() throws IOException {
        HttpResponse response = executeUnparsed();
        com.google.api.services.gan.model.Links result = response.parseAs(
            com.google.api.services.gan.model.Links.class);
        result.setResponseHeaders(response.getHeaders());
        return result;
      }

      /**
       * Queues the "list" request to the Gan server into the given batch request.
       *
       * <p>
       * Example usage:
       * </p>
       *
       * <pre>
         request.queue(batchRequest, new JsonBatchCallback&lt;Links&gt;() {

           public void onSuccess(Links content, GoogleHeaders responseHeaders) {
             log("Success");
           }

           public void onFailure(GoogleJsonError e, GoogleHeaders responseHeaders) {
             log(e.getMessage());
           }
         });
       * </pre>
       *
       * @param batch a single batch of requests
       * @param callback batch callback
       * @since 1.6
       */
      public void queue(com.google.api.client.googleapis.batch.BatchRequest batch,
          com.google.api.client.googleapis.batch.json.JsonBatchCallback<com.google.api.services.gan.model.Links> callback)
          throws IOException {
        batch.queue(buildHttpRequest(), com.google.api.services.gan.model.Links.class,
            com.google.api.client.googleapis.json.GoogleJsonErrorContainer.class, callback);
      }

      /**
       * @since 1.7
       */
      @Override
      public List setFields(String fields) {
        super.setFields(fields);
        return this;
      }

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      @com.google.api.client.util.Key
      private String role;

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'.
       */
      public String getRole() {
        return role;
      }

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      public List setRole(String role) {
        this.role = role;
        return this;
      }

      /** The ID of the requesting advertiser or publisher. */
      @com.google.api.client.util.Key
      private String roleId;

      /** The ID of the requesting advertiser or publisher.
       */
      public String getRoleId() {
        return roleId;
      }

      /** The ID of the requesting advertiser or publisher. */
      public List setRoleId(String roleId) {
        this.roleId = roleId;
        return this;
      }

      /** The type of the link. */
      @com.google.api.client.util.Key
      private String linkType;

      /** The type of the link.
       */
      public String getLinkType() {
        return linkType;
      }

      /** The type of the link. */
      public List setLinkType(String linkType) {
        this.linkType = linkType;
        return this;
      }

      /** The beginning of the start date range. */
      @com.google.api.client.util.Key
      private String startDateMin;

      /** The beginning of the start date range.
       */
      public String getStartDateMin() {
        return startDateMin;
      }

      /** The beginning of the start date range. */
      public List setStartDateMin(String startDateMin) {
        this.startDateMin = startDateMin;
        return this;
      }

      /** The size of the given asset. */
      @com.google.api.client.util.Key
      private java.util.List<String> assetSize;

      /** The size of the given asset.
       */
      public java.util.List<String> getAssetSize() {
        return assetSize;
      }

      /** The size of the given asset. */
      public List setAssetSize(java.util.List<String> assetSize) {
        this.assetSize = assetSize;
        return this;
      }

      /** The status of the relationship. */
      @com.google.api.client.util.Key
      private String relationshipStatus;

      /** The status of the relationship.
       */
      public String getRelationshipStatus() {
        return relationshipStatus;
      }

      /** The status of the relationship. */
      public List setRelationshipStatus(String relationshipStatus) {
        this.relationshipStatus = relationshipStatus;
        return this;
      }

      /** The advertiser's primary vertical. */
      @com.google.api.client.util.Key
      private java.util.List<String> advertiserCategory;

      /** The advertiser's primary vertical.
       */
      public java.util.List<String> getAdvertiserCategory() {
        return advertiserCategory;
      }

      /** The advertiser's primary vertical. */
      public List setAdvertiserCategory(java.util.List<String> advertiserCategory) {
        this.advertiserCategory = advertiserCategory;
        return this;
      }

      /** Max number of items to return in this page. Optional. Defaults to 20. */
      @com.google.api.client.util.Key
      private Long maxResults;

      /** Max number of items to return in this page. Optional. Defaults to 20.

     [minimum: 0] [maximum: 100]
       */
      public Long getMaxResults() {
        return maxResults;
      }

      /** Max number of items to return in this page. Optional. Defaults to 20. */
      public List setMaxResults(Long maxResults) {
        this.maxResults = maxResults;
        return this;
      }

      /** Limits the resulting links to the ones belonging to the listed advertisers. */
      @com.google.api.client.util.Key
      private java.util.List<Long> advertiserId;

      /** Limits the resulting links to the ones belonging to the listed advertisers.
       */
      public java.util.List<Long> getAdvertiserId() {
        return advertiserId;
      }

      /** Limits the resulting links to the ones belonging to the listed advertisers. */
      public List setAdvertiserId(java.util.List<Long> advertiserId) {
        this.advertiserId = advertiserId;
        return this;
      }

      /** The value of 'nextPageToken' from the previous page. Optional. */
      @com.google.api.client.util.Key
      private String pageToken;

      /** The value of 'nextPageToken' from the previous page. Optional.
       */
      public String getPageToken() {
        return pageToken;
      }

      /** The value of 'nextPageToken' from the previous page. Optional. */
      public List setPageToken(String pageToken) {
        this.pageToken = pageToken;
        return this;
      }

      /** The end of the start date range. */
      @com.google.api.client.util.Key
      private String startDateMax;

      /** The end of the start date range.
       */
      public String getStartDateMax() {
        return startDateMax;
      }

      /** The end of the start date range. */
      public List setStartDateMax(String startDateMax) {
        this.startDateMax = startDateMax;
        return this;
      }

      /** The promotion type. */
      @com.google.api.client.util.Key
      private java.util.List<String> promotionType;

      /** The promotion type.
       */
      public java.util.List<String> getPromotionType() {
        return promotionType;
      }

      /** The promotion type. */
      public List setPromotionType(java.util.List<String> promotionType) {
        this.promotionType = promotionType;
        return this;
      }

      /** The role of the author of the link. */
      @com.google.api.client.util.Key
      private String authorship;

      /** The role of the author of the link.
       */
      public String getAuthorship() {
        return authorship;
      }

      /** The role of the author of the link. */
      public List setAuthorship(String authorship) {
        this.authorship = authorship;
        return this;
      }

    }
    /**
     * Retrieves data about a single link if the requesting advertiser/publisher has access to it.
     * Advertisers can look up their own links. Publishers can look up visible links or links belonging
     * to advertisers they are in a relationship with.
     *
     * Create a request for the method "links.get".
     *
     * This request holds the parameters needed by the the gan server.  After setting any optional
     * parameters, call the {@link Get#execute()} method to invoke the remote operation.
     *
     * @param role The role of the requester. Valid values: 'advertisers' or 'publishers'.
     * @param roleId The ID of the requesting advertiser or publisher.
     * @param linkId The ID of the link to look up.
     * @return the request
     * @throws IOException if the initialization of the request fails
     */
    public Get get(String role, String roleId, Long linkId) throws IOException {
      Get result = new Get(role, roleId, linkId);
      initialize(result);
      return result;
    }

    public class Get extends GanRequest {

      private static final String REST_PATH = "{role}/{roleId}/link/{linkId}";

      /**
       * Internal constructor.  Use the convenience method instead.
       */
      Get(String role, String roleId, Long linkId) {
        super(Gan.this, HttpMethod.GET, REST_PATH, null);
        this.role = Preconditions.checkNotNull(role, "Required parameter role must be specified.");
        this.roleId = Preconditions.checkNotNull(roleId, "Required parameter roleId must be specified.");
        this.linkId = Preconditions.checkNotNull(linkId, "Required parameter linkId must be specified.");
      }

      /**
       * Sends the "get" request to the Gan server.
       *
       * @return the {@link com.google.api.services.gan.model.Link} response
       * @throws IOException if the request fails
       */
      public com.google.api.services.gan.model.Link execute() throws IOException {
        HttpResponse response = executeUnparsed();
        com.google.api.services.gan.model.Link result = response.parseAs(
            com.google.api.services.gan.model.Link.class);
        result.setResponseHeaders(response.getHeaders());
        return result;
      }

      /**
       * Queues the "get" request to the Gan server into the given batch request.
       *
       * <p>
       * Example usage:
       * </p>
       *
       * <pre>
         request.queue(batchRequest, new JsonBatchCallback&lt;Link&gt;() {

           public void onSuccess(Link content, GoogleHeaders responseHeaders) {
             log("Success");
           }

           public void onFailure(GoogleJsonError e, GoogleHeaders responseHeaders) {
             log(e.getMessage());
           }
         });
       * </pre>
       *
       * @param batch a single batch of requests
       * @param callback batch callback
       * @since 1.6
       */
      public void queue(com.google.api.client.googleapis.batch.BatchRequest batch,
          com.google.api.client.googleapis.batch.json.JsonBatchCallback<com.google.api.services.gan.model.Link> callback)
          throws IOException {
        batch.queue(buildHttpRequest(), com.google.api.services.gan.model.Link.class,
            com.google.api.client.googleapis.json.GoogleJsonErrorContainer.class, callback);
      }

      /**
       * @since 1.7
       */
      @Override
      public Get setFields(String fields) {
        super.setFields(fields);
        return this;
      }

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      @com.google.api.client.util.Key
      private String role;

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'.
       */
      public String getRole() {
        return role;
      }

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      public Get setRole(String role) {
        this.role = role;
        return this;
      }

      /** The ID of the requesting advertiser or publisher. */
      @com.google.api.client.util.Key
      private String roleId;

      /** The ID of the requesting advertiser or publisher.
       */
      public String getRoleId() {
        return roleId;
      }

      /** The ID of the requesting advertiser or publisher. */
      public Get setRoleId(String roleId) {
        this.roleId = roleId;
        return this;
      }

      /** The ID of the link to look up. */
      @com.google.api.client.util.Key
      private Long linkId;

      /** The ID of the link to look up.
       */
      public Long getLinkId() {
        return linkId;
      }

      /** The ID of the link to look up. */
      public Get setLinkId(Long linkId) {
        this.linkId = linkId;
        return this;
      }

    }

  }

  /**
   * An accessor for creating requests from the Publishers collection.
   *
   * The typical use is:<pre>
   *   {@code Gan gan = new Gan(...);}
   *   {@code Gan.Publishers.List request = gan.publishers().list(parameters ...)}</pre>
   *
   * @return the resource collection
   */
  public Publishers publishers() {
    return new Publishers();
  }

  /**
   * The "publishers" collection of methods.
   */
  public class Publishers {

    /**
     * Retrieves data about all publishers that the requesting advertiser/publisher has access to.
     *
     * Create a request for the method "publishers.list".
     *
     * This request holds the parameters needed by the the gan server.  After setting any optional
     * parameters, call the {@link List#execute()} method to invoke the remote operation.
     *
     * @param role The role of the requester. Valid values: 'advertisers' or 'publishers'.
     * @param roleId The ID of the requesting advertiser or publisher.
     * @return the request
     * @throws IOException if the initialization of the request fails
     */
    public List list(String role, String roleId) throws IOException {
      List result = new List(role, roleId);
      initialize(result);
      return result;
    }

    public class List extends GanRequest {

      private static final String REST_PATH = "{role}/{roleId}/publishers";

      /**
       * Internal constructor.  Use the convenience method instead.
       */
      List(String role, String roleId) {
        super(Gan.this, HttpMethod.GET, REST_PATH, null);
        this.role = Preconditions.checkNotNull(role, "Required parameter role must be specified.");
        this.roleId = Preconditions.checkNotNull(roleId, "Required parameter roleId must be specified.");
      }

      /**
       * Sends the "list" request to the Gan server.
       *
       * @return the {@link com.google.api.services.gan.model.Publishers} response
       * @throws IOException if the request fails
       */
      public com.google.api.services.gan.model.Publishers execute() throws IOException {
        HttpResponse response = executeUnparsed();
        com.google.api.services.gan.model.Publishers result = response.parseAs(
            com.google.api.services.gan.model.Publishers.class);
        result.setResponseHeaders(response.getHeaders());
        return result;
      }

      /**
       * Queues the "list" request to the Gan server into the given batch request.
       *
       * <p>
       * Example usage:
       * </p>
       *
       * <pre>
         request.queue(batchRequest, new JsonBatchCallback&lt;Publishers&gt;() {

           public void onSuccess(Publishers content, GoogleHeaders responseHeaders) {
             log("Success");
           }

           public void onFailure(GoogleJsonError e, GoogleHeaders responseHeaders) {
             log(e.getMessage());
           }
         });
       * </pre>
       *
       * @param batch a single batch of requests
       * @param callback batch callback
       * @since 1.6
       */
      public void queue(com.google.api.client.googleapis.batch.BatchRequest batch,
          com.google.api.client.googleapis.batch.json.JsonBatchCallback<com.google.api.services.gan.model.Publishers> callback)
          throws IOException {
        batch.queue(buildHttpRequest(), com.google.api.services.gan.model.Publishers.class,
            com.google.api.client.googleapis.json.GoogleJsonErrorContainer.class, callback);
      }

      /**
       * @since 1.7
       */
      @Override
      public List setFields(String fields) {
        super.setFields(fields);
        return this;
      }

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      @com.google.api.client.util.Key
      private String role;

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'.
       */
      public String getRole() {
        return role;
      }

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      public List setRole(String role) {
        this.role = role;
        return this;
      }

      /** The ID of the requesting advertiser or publisher. */
      @com.google.api.client.util.Key
      private String roleId;

      /** The ID of the requesting advertiser or publisher.
       */
      public String getRoleId() {
        return roleId;
      }

      /** The ID of the requesting advertiser or publisher. */
      public List setRoleId(String roleId) {
        this.roleId = roleId;
        return this;
      }

      /**
     * Caret(^) delimted list of publisher categories. Valid categories: (unclassified|community_and
     * _content|shopping_and_promotion|loyalty_and_rewards|network|search_specialist|comparison_shop
     * ping|email). Filters out all publishers not in one of the given advertiser categories.
     * Optional.
     */
      @com.google.api.client.util.Key
      private String publisherCategory;

      /** Caret(^) delimted list of publisher categories. Valid categories: (unclassified|community_and_conte
     nt|shopping_and_promotion|loyalty_and_rewards|network|search_specialist|comparison_shopping|email).
     Filters out all publishers not in one of the given advertiser categories. Optional.
       */
      public String getPublisherCategory() {
        return publisherCategory;
      }

      /**
     * Caret(^) delimted list of publisher categories. Valid categories: (unclassified|community_and
     * _content|shopping_and_promotion|loyalty_and_rewards|network|search_specialist|comparison_shop
     * ping|email). Filters out all publishers not in one of the given advertiser categories.
     * Optional.
     */
      public List setPublisherCategory(String publisherCategory) {
        this.publisherCategory = publisherCategory;
        return this;
      }

      /**
     * Filters out all publishers for which do not have the given relationship status with the
     * requesting publisher.
     */
      @com.google.api.client.util.Key
      private String relationshipStatus;

      /** Filters out all publishers for which do not have the given relationship status with the requesting
     publisher.
       */
      public String getRelationshipStatus() {
        return relationshipStatus;
      }

      /**
     * Filters out all publishers for which do not have the given relationship status with the
     * requesting publisher.
     */
      public List setRelationshipStatus(String relationshipStatus) {
        this.relationshipStatus = relationshipStatus;
        return this;
      }

      /**
     * Filters out all publishers that have a seven day EPC average lower than the given value
     * (inclusive). Min value 0.0. Optional.
     */
      @com.google.api.client.util.Key
      private Double minSevenDayEpc;

      /** Filters out all publishers that have a seven day EPC average lower than the given value
     (inclusive). Min value 0.0. Optional.
       */
      public Double getMinSevenDayEpc() {
        return minSevenDayEpc;
      }

      /**
     * Filters out all publishers that have a seven day EPC average lower than the given value
     * (inclusive). Min value 0.0. Optional.
     */
      public List setMinSevenDayEpc(Double minSevenDayEpc) {
        this.minSevenDayEpc = minSevenDayEpc;
        return this;
      }

      /**
     * Filters out all publishers that have a ninety day EPC average lower than the given value
     * (inclusive). Min value: 0.0. Optional.
     */
      @com.google.api.client.util.Key
      private Double minNinetyDayEpc;

      /** Filters out all publishers that have a ninety day EPC average lower than the given value
     (inclusive). Min value: 0.0. Optional.
       */
      public Double getMinNinetyDayEpc() {
        return minNinetyDayEpc;
      }

      /**
     * Filters out all publishers that have a ninety day EPC average lower than the given value
     * (inclusive). Min value: 0.0. Optional.
     */
      public List setMinNinetyDayEpc(Double minNinetyDayEpc) {
        this.minNinetyDayEpc = minNinetyDayEpc;
        return this;
      }

      /** The value of 'nextPageToken' from the previous page. Optional. */
      @com.google.api.client.util.Key
      private String pageToken;

      /** The value of 'nextPageToken' from the previous page. Optional.
       */
      public String getPageToken() {
        return pageToken;
      }

      /** The value of 'nextPageToken' from the previous page. Optional. */
      public List setPageToken(String pageToken) {
        this.pageToken = pageToken;
        return this;
      }

      /** Max number of items to return in this page. Optional. Defaults to 20. */
      @com.google.api.client.util.Key
      private Long maxResults;

      /** Max number of items to return in this page. Optional. Defaults to 20.

     [minimum: 0] [maximum: 100]
       */
      public Long getMaxResults() {
        return maxResults;
      }

      /** Max number of items to return in this page. Optional. Defaults to 20. */
      public List setMaxResults(Long maxResults) {
        this.maxResults = maxResults;
        return this;
      }

      /**
     * A value between 1 and 4, where 1 represents the quartile of publishers with the lowest ranks
     * and 4 represents the quartile of publishers with the highest ranks. Filters out all
     * publishers with a lower rank than the given quartile. For example if a 2 was given only
     * publishers with a payout rank of 25 or higher would be included. Optional.
     */
      @com.google.api.client.util.Key
      private Integer minPayoutRank;

      /** A value between 1 and 4, where 1 represents the quartile of publishers with the lowest ranks and 4
     represents the quartile of publishers with the highest ranks. Filters out all publishers with a
     lower rank than the given quartile. For example if a 2 was given only publishers with a payout rank
     of 25 or higher would be included. Optional.

     [minimum: 1] [maximum: 4]
       */
      public Integer getMinPayoutRank() {
        return minPayoutRank;
      }

      /**
     * A value between 1 and 4, where 1 represents the quartile of publishers with the lowest ranks
     * and 4 represents the quartile of publishers with the highest ranks. Filters out all
     * publishers with a lower rank than the given quartile. For example if a 2 was given only
     * publishers with a payout rank of 25 or higher would be included. Optional.
     */
      public List setMinPayoutRank(Integer minPayoutRank) {
        this.minPayoutRank = minPayoutRank;
        return this;
      }

    }
    /**
     * Retrieves data about a single advertiser if that the requesting advertiser/publisher has access
     * to it. Only advertisers can look up publishers. Publishers can request information about
     * themselves by omitting the publisherId query parameter.
     *
     * Create a request for the method "publishers.get".
     *
     * This request holds the parameters needed by the the gan server.  After setting any optional
     * parameters, call the {@link Get#execute()} method to invoke the remote operation.
     *
     * @param role The role of the requester. Valid values: 'advertisers' or 'publishers'.
     * @param roleId The ID of the requesting advertiser or publisher.
     * @return the request
     * @throws IOException if the initialization of the request fails
     */
    public Get get(String role, String roleId) throws IOException {
      Get result = new Get(role, roleId);
      initialize(result);
      return result;
    }

    public class Get extends GanRequest {

      private static final String REST_PATH = "{role}/{roleId}/publisher";

      /**
       * Internal constructor.  Use the convenience method instead.
       */
      Get(String role, String roleId) {
        super(Gan.this, HttpMethod.GET, REST_PATH, null);
        this.role = Preconditions.checkNotNull(role, "Required parameter role must be specified.");
        this.roleId = Preconditions.checkNotNull(roleId, "Required parameter roleId must be specified.");
      }

      /**
       * Sends the "get" request to the Gan server.
       *
       * @return the {@link com.google.api.services.gan.model.Publisher} response
       * @throws IOException if the request fails
       */
      public com.google.api.services.gan.model.Publisher execute() throws IOException {
        HttpResponse response = executeUnparsed();
        com.google.api.services.gan.model.Publisher result = response.parseAs(
            com.google.api.services.gan.model.Publisher.class);
        result.setResponseHeaders(response.getHeaders());
        return result;
      }

      /**
       * Queues the "get" request to the Gan server into the given batch request.
       *
       * <p>
       * Example usage:
       * </p>
       *
       * <pre>
         request.queue(batchRequest, new JsonBatchCallback&lt;Publisher&gt;() {

           public void onSuccess(Publisher content, GoogleHeaders responseHeaders) {
             log("Success");
           }

           public void onFailure(GoogleJsonError e, GoogleHeaders responseHeaders) {
             log(e.getMessage());
           }
         });
       * </pre>
       *
       * @param batch a single batch of requests
       * @param callback batch callback
       * @since 1.6
       */
      public void queue(com.google.api.client.googleapis.batch.BatchRequest batch,
          com.google.api.client.googleapis.batch.json.JsonBatchCallback<com.google.api.services.gan.model.Publisher> callback)
          throws IOException {
        batch.queue(buildHttpRequest(), com.google.api.services.gan.model.Publisher.class,
            com.google.api.client.googleapis.json.GoogleJsonErrorContainer.class, callback);
      }

      /**
       * @since 1.7
       */
      @Override
      public Get setFields(String fields) {
        super.setFields(fields);
        return this;
      }

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      @com.google.api.client.util.Key
      private String role;

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'.
       */
      public String getRole() {
        return role;
      }

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      public Get setRole(String role) {
        this.role = role;
        return this;
      }

      /** The ID of the requesting advertiser or publisher. */
      @com.google.api.client.util.Key
      private String roleId;

      /** The ID of the requesting advertiser or publisher.
       */
      public String getRoleId() {
        return roleId;
      }

      /** The ID of the requesting advertiser or publisher. */
      public Get setRoleId(String roleId) {
        this.roleId = roleId;
        return this;
      }

      /** The ID of the publisher to look up. Optional. */
      @com.google.api.client.util.Key
      private String publisherId;

      /** The ID of the publisher to look up. Optional.
       */
      public String getPublisherId() {
        return publisherId;
      }

      /** The ID of the publisher to look up. Optional. */
      public Get setPublisherId(String publisherId) {
        this.publisherId = publisherId;
        return this;
      }

    }

  }

  /**
   * Builder for {@link Gan}.
   *
   * <p>
   * Implementation is not thread-safe.
   * </p>
   *
   * @since 1.3.0
   */
  public static final class Builder extends GoogleClient.Builder {

    /**
     * Returns an instance of a new builder.
     *
     * @param transport The transport to use for requests
     * @param jsonFactory A factory for creating JSON parsers and serializers
     * @param baseUrl The base URL of the service. Must end with a "/"
     */
    @Deprecated
    Builder(HttpTransport transport, JsonFactory jsonFactory, GenericUrl baseUrl) {
      super(transport, jsonFactory, baseUrl);
    }

    /**
     * Returns an instance of a new builder.
     *
     * @param transport The transport to use for requests
     * @param jsonFactory A factory for creating JSON parsers and serializers
     * @param httpRequestInitializer The HTTP request initializer or {@code null} for none
     * @since 1.7
     */
    public Builder(HttpTransport transport, JsonFactory jsonFactory,
        HttpRequestInitializer httpRequestInitializer) {
      super(transport, jsonFactory, DEFAULT_ROOT_URL, DEFAULT_SERVICE_PATH, httpRequestInitializer);
    }

    /** Builds a new instance of {@link Gan}. */
    @SuppressWarnings("deprecation")
    @Override
    public Gan build() {
      if (isBaseUrlUsed()) {
        return new Gan(
            getTransport(),
            getJsonHttpRequestInitializer(),
            getHttpRequestInitializer(),
            getJsonFactory(),
            getObjectParser(),
            getBaseUrl().build(),
            getApplicationName());
      }
      return new Gan(
          getTransport(),
          getJsonHttpRequestInitializer(),
          getHttpRequestInitializer(),
          getJsonFactory(),
          getObjectParser(),
          getRootUrl(),
          getServicePath(),
          getApplicationName());
    }

    @Override
    @Deprecated
    public Builder setBaseUrl(GenericUrl baseUrl) {
      super.setBaseUrl(baseUrl);
      return this;
    }

    @Override
    public Builder setRootUrl(String rootUrl) {
      super.setRootUrl(rootUrl);
      return this;
    }

    @Override
    public Builder setServicePath(String servicePath) {
      super.setServicePath(servicePath);
      return this;
    }

    @Override
    public Builder setJsonHttpRequestInitializer(
        JsonHttpRequestInitializer jsonHttpRequestInitializer) {
      super.setJsonHttpRequestInitializer(jsonHttpRequestInitializer);
      return this;
    }

    @Override
    public Builder setHttpRequestInitializer(HttpRequestInitializer httpRequestInitializer) {
      super.setHttpRequestInitializer(httpRequestInitializer);
      return this;
    }

    @Override
    public Builder setApplicationName(String applicationName) {
      super.setApplicationName(applicationName);
      return this;
    }

    @Override
    public Builder setObjectParser(JsonObjectParser parser) {
      super.setObjectParser(parser);
      return this;
    }
  }
}
